'use strict'
const events = require('events')
    //会话类(用户连接类)
class Session extends events.EventEmitter {
    constructor(sId, socket) {
        super()
        this.id = sId
        this.pId = null //登陆的角色id
        this.sceneId = null //角色所在的场景id
        this.nodeId = null //角色所在的节点服务器id
        this.uId = null //角色的用户id
        this.socket = socket
        this.heartbeat = 0 //心跳
        this.handleSocket(socket)
    }
    handleSocket(socket) {
        let self = this
        socket.on('close', function(data) {
            self.emit('close', {
                session: self
            })
        })
        socket.on('error', function(data) {
            this.emit('close')
        })
    }
}
module.exports = Session
